package com.tc.utils;

import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import java.util.Date;
import java.util.Map;

public class JWT {
    private static final String SECRET = "yyzx";
    private static final long EXPIRATION = 1000 * 60 * 60 * 24;

    public static String createToken(String subject, String id, Map<String, Object> claims) {
        JwtBuilder builder = Jwts.builder();
        return builder.setSubject(subject)
                .setIssuedAt(new Date())
                .setId(id)
                .setClaims(claims)
                .setExpiration(new Date(System.currentTimeMillis() + EXPIRATION))
                .signWith(SignatureAlgorithm.HS256, SECRET)
                .compact();
    }
}
